Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): new unique-id validator #2134

Merged
merged 17 commits into from
Jan 25, 2024
Merged

fix(core): new unique-id validator #2134

merged 17 commits into from
Jan 25, 2024

Conversation

sleidig
Copy link
Member

@sleidig sleidig commented Dec 18, 2023

to prevent creating duplicate user ids in form

fixes #1557

Visible/Frontend Changes

  • form field is marked invalid if the username field value already exists

Architectural/Backend Changes

  • a general "uniqueId" validator is added, usable via entity schema config
  • the DynamicValidatorService has to run async now for this advance validator to be build

TODO

  • detect original value and allow to revert to that

Copy link

Deployed to https://pr-2134.aam-digital.net/

Copy link
Collaborator

@TheSlimvReal TheSlimvReal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would definitely want to keep the validators already built in the form service. This is supposed to be a complete service so that it returns you the full form with everything set up so it can also be used at other places.

What exactly do you mean with the DI validator architecture? Like the refactoring we recently did for the data types?

Copy link
Collaborator

@TheSlimvReal TheSlimvReal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I directly press "save" I sometimes still get the conflict update message. It seems like it doesn't wait for the validator. Can we ensure this somehow?

Copy link
Collaborator

@TheSlimvReal TheSlimvReal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discovered one more issue on existing records. E.g. when editing the name field of a existing user entity but changing the original name there, it still doesn't allow to save it.

@sleidig sleidig closed this Jan 22, 2024
@sleidig sleidig reopened this Jan 22, 2024
@sleidig
Copy link
Member Author

sleidig commented Jan 22, 2024

I discovered one more issue on existing records. E.g. when editing the name field of a existing user entity but changing the original name there, it still doesn't allow to save it.

This is consistent with current behavior, enforced by the User entity. I think that will become obsolete with your PR #2143 (are you removing the special username property there already?). Not super user-friendly but as this unique-id validator is intended for more general use, I would ignore this here. What do you think, @TheSlimvReal ?

aam-digital-ci and others added 10 commits January 22, 2024 19:03
Co-authored-by: snyk-bot <snyk-bot@snyk.io>
…2179)

Co-authored-by: snyk-bot <snyk-bot@snyk.io>
Co-authored-by: Simon <simon@aam-digital.com>
Co-authored-by: Simon <simon@aam-digital.com>
# Conflicts:
#	src/app/child-dev-project/children/health-checkup/health-checkup-component/health-checkup.component.html
#	src/app/child-dev-project/children/health-checkup/health-checkup-component/health-checkup.component.ts
#	src/app/features/historical-data/historical-data/historical-data.component.ts
Copy link
Collaborator

@TheSlimvReal TheSlimvReal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General use case works well.

Some other issues that still exist though:

  • Pressing cancel clears the input field (unrelated)
  • Usernames equality is checked case sensitive which might still create conflicts in some cases (keycloak only saves lower case)
  • Existing (unmodified) usernames cannot be saved once form field is dirty

@sleidig sleidig closed this Jan 25, 2024
@sleidig sleidig reopened this Jan 25, 2024
Copy link

Deployed to https://pr-2134.aam-digital.net/

@sleidig sleidig merged commit 9f8f15e into master Jan 25, 2024
8 of 11 checks passed
@sleidig sleidig deleted the user-duplicate branch January 25, 2024 17:00
@aam-digital-ci
Copy link
Collaborator

🎉 This PR is included in version 3.30.0-master.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@aam-digital-ci aam-digital-ci added the released on @master managed by CI (semantic-release) label Jan 25, 2024
@aam-digital-ci
Copy link
Collaborator

🎉 This PR is included in version 3.30.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@aam-digital-ci aam-digital-ci added the released managed by CI (semantic-release) label Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released on @master managed by CI (semantic-release) released managed by CI (semantic-release)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creating a user with a username that already exists produces a local db conflict
4 participants